package org.duanyu.controller;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 对话模型控制器
 */
@RestController
public class ChatController {

    @Autowired
    private ChatModel chatModel;

    @GetMapping("/chat")
    public String chat(String message){
        //call呼叫
        ChatResponse call = chatModel.call(new Prompt(message));
        return call.getResult().getOutput().getContent();


    }

}
